<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>更新</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<include file="common/tag"/>
	</head>
	<link rel="stylesheet" href="/static/plugin/ace/css/chosen.css" />
	<script src="/static/plugin/ace/js/chosen.jquery.min.js"></script>
	<script src="/static/plugin/ace/js/jquery.autosize.min.js"></script>
	<script src="/static/plugin/ace/js/jquery.inputlimiter.1.3.1.min.js"></script>
	<style>
		body{
			background-color:#fff
		}
		.yui_right{
			float: right;
			margin-bottom: 10px;
		}
		#container {
			width: 95%;
			height: 300px;
		}
	</style>
	<body >
	<div>
		<div class="widget-main">

			<input type="hidden" name="id" value="{$data.id}"/>

			<div>
				<label >状态</label>
				<select class="form-control" name="status">
					<eq name="data.status" value="1">
						<option value="1" selected>开启</option>
						<option value="0">关闭</option>
						<else/>
						<option value="0" selected>关闭</option>
						<option value="1">开启</option>
					</eq>
				</select>
			</div>

			<br>

			<div>
				<label >欢迎语</label>
				<textarea class="autosize-transition form-control" name="index_wel">{$data.index_wel}</textarea>
			</div>

			<br>

			<div>
				<label >格言</label>
				<textarea class="autosize-transition form-control" name="index_motto">{$data.index_motto}</textarea>
			</div>

			<br>

			<div>
				<label >关于本站</label>
				<textarea class="autosize-transition form-control" name="index_about">{$data.index_about}</textarea>
			</div>

			<br>

			<button class="btn btn-primary yui_right" id="yui_save">
				<i class="icon-plus align-top bigger-125"></i>
				保存
			</button>

		</div>
	</div>

	</body>
	<script>
		$(function () {
            $(".chosen-select").chosen();
            $('textarea[class*=autosize]').autosize({append: "\n"});
            $('textarea.limited').inputlimiter({
                remText: '%n character%s remaining...',
                limitText: 'max allowed : %n.'
            });

            $("#yui_save").on('click' , function(){
                var id=$("input[name='id']").val();
                var status=$("select[name='status']").val();
                var index_wel=$("textarea[name='index_wel']").val();
                var index_motto=$("textarea[name='index_motto']").val();
                var index_about=$("textarea[name='index_about']").val();
				//ajax提交数据
				$.post("/index.php/admin/index/index_edit",
					{
						id:id,
                        index_wel:index_wel,
                        index_motto:index_motto,
                        index_about:index_about,
						status:status
					},
					function(data,status){
						if (data['code']==1){
							layer.open({
								title: '提示',
								content: '操作成功'
								,yes: function(index, layero){
									window.parent.location.reload();
								},cancel: function(){
									window.parent.location.reload();
								}
							});
						}else{
							layer.msg(data['text']);
						}
					}, "json"
				);

            });

        });
	</script>

</html>
